//
//  JinTableViewCell.swift
//  lottery
//
//  Created by admin on 16/2/3.
//  Copyright © 2016年 jin. All rights reserved.
//

import UIKit

class JinTableViewCell: UITableViewCell {
    // 获得一个cell类
    class func instance(tableView:UITableView,setingData:Setting)->UITableViewCell
    {
        var cell:UITableViewCell! = tableView.dequeueReusableCellWithIdentifier("setting")
        cell = cell == nil ? UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "setting") : cell
        if setingData.accessoryImage != nil
        {
            cell.accessoryView = UIImageView(image: setingData.accessoryImage)
        }
        else if setingData.accessory is UISwitch
        {
            let switcha = (setingData.accessory as! UISwitch)
            switcha.addTarget(setingData, action: "switchChange:", forControlEvents: UIControlEvents.ValueChanged)
            cell.accessoryView = switcha
            cell.selectionStyle = UITableViewCellSelectionStyle.None
        }
        else if setingData.accessory is UILabel
        {
            let lable = (setingData.accessory as! UILabel)
            lable.bounds = CGRectMake(0, 0, 50, 44)
            cell.accessoryView = (setingData.accessory as! UILabel)
        }
        cell.textLabel?.text = setingData.title
        cell.imageView?.image = setingData.titleImage
        return cell
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    
}
